/*
 * @lc app=leetcode.cn id=187 lang=csharp
 *
 * [187] 重复的DNA序列
 */

// @lc code=start
public class Solution {
    public IList<string> FindRepeatedDnaSequences(string s) {
        var res = new List<string>();
        if (s.Length < 10)
        {
            return res;
        }
        var dict = new Dictionary<string, int>();
        for (int i = 0; i <= s.Length - 10; i++)
        {
            var sub = s.Substring(i, 10);
            if (dict.ContainsKey(sub))
            {
                if (dict[sub] == 1)
                {
                    res.Add(sub);
                }
                dict[sub]++;
            }
            else
            {
                dict.Add(sub, 1);
            }
        }
        return res;
        
    }
}
// @lc code=end

